﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:Sample="clr-namespace:GraphSharp.Sample" 
	xmlns:GraphSharp_Controls="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls" 
	xmlns:Converters="clr-namespace:GraphSharp.Converters;assembly=GraphSharp.Controls"
	xmlns:WPFExtensions_AttachedBehaviours="clr-namespace:WPFExtensions.AttachedBehaviours;assembly=WPFExtensions">
	
	<Converters:EdgeRouteToPathConverter x:Key="routeToPathConverter" />
	
	<SolidColorBrush x:Key="HighlightedVertexBorderBrush" Color="Transparent" />
	<SolidColorBrush x:Key="HighlightedVertexBackgroundBrush" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
	<SolidColorBrush x:Key="HighlightedVertexForegroundBrush" Color="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}" />
	<SolidColorBrush x:Key="SemiHighlightedSourceVertexBorderBrush" Color="Transparent" />
	<SolidColorBrush x:Key="SemiHighlightedSourceVertexBackgroundBrush" Color="#FF1DBA00" />
	<SolidColorBrush x:Key="SemiHighlightedTargetVertexBorderBrush" Color="Transparent" />
	<SolidColorBrush x:Key="SemiHighlightedTargetVertexBackgroundBrush" Color="#FFD6A51C" />
	<SolidColorBrush x:Key="HighlightedEdgeBrush" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
	<SolidColorBrush x:Key="SemiHighlightedInEdgeBrush" Color="#FF1DBA00" />
	<SolidColorBrush x:Key="SemiHighlightedOutEdgeBrush" Color="#FFD6A51C" />
	
	<DataTemplate DataType="{x:Type Sample:PocVertex}">
		<TextBlock Text="{Binding Path=ID, Mode=OneWay, FallbackValue=VertexId}" />
    </DataTemplate>
	
	
	<!-- VERTEX CONTROL -->
	<Style TargetType="{x:Type GraphSharp_Controls:VertexControl}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type GraphSharp_Controls:VertexControl}">
					<Border Background="{TemplateBinding Background}" 
							BorderBrush="{TemplateBinding BorderBrush}" 
							BorderThickness="{TemplateBinding BorderThickness}"
							CornerRadius="10,10,10,10"
							Padding="{TemplateBinding Padding}">
						<ContentPresenter Content="{TemplateBinding Vertex}"/>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger" Value="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}"/>
		<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.IsDragEnabled" Value="True"/>
		<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.X" Value="{Binding Path=(GraphSharp_Controls:GraphCanvas.X), Mode=TwoWay, RelativeSource={RelativeSource Self}}"/>
		<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.Y" Value="{Binding Path=(GraphSharp_Controls:GraphCanvas.Y), Mode=TwoWay, RelativeSource={RelativeSource Self}}"/>
		<Setter Property="Background" Value="#FFE3E3E3"/>
		<Setter Property="BorderThickness" Value="5,3,5,3"/>
		<Setter Property="Padding" Value="10,5,10,5"/>
		<Setter Property="BorderBrush" Value="#FF393939"/>
		<Style.Triggers>
			<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted" Value="True">
				<Setter Property="BorderBrush" Value="{StaticResource HighlightedVertexBorderBrush}"/>
				<Setter Property="Background" Value="{StaticResource HighlightedVertexBackgroundBrush}"/>
				<Setter Property="Foreground" Value="{StaticResource HighlightedVertexForegroundBrush}"/>
			</Trigger>
			<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True">
				<Setter Property="BorderBrush" Value="{StaticResource HighlightedVertexBorderBrush}"/>
				<Setter Property="Background" Value="{StaticResource HighlightedVertexBackgroundBrush}"/>
				<Setter Property="Foreground" Value="{StaticResource HighlightedVertexForegroundBrush}"/>
			</Trigger>
			<MultiTrigger>
				<MultiTrigger.Conditions>
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"/>
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" Value="Source"/>
				</MultiTrigger.Conditions>
				<Setter Property="BorderBrush" Value="{StaticResource SemiHighlightedSourceVertexBorderBrush}"/>
				<Setter Property="Background" Value="{StaticResource SemiHighlightedSourceVertexBackgroundBrush}"/>
			</MultiTrigger>
			<MultiTrigger>
				<MultiTrigger.Conditions>
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"/>
					<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" Value="Target"/>
				</MultiTrigger.Conditions>
				<Setter Property="BorderBrush" Value="{StaticResource SemiHighlightedTargetVertexBorderBrush}"/>
				<Setter Property="Background" Value="{StaticResource SemiHighlightedTargetVertexBackgroundBrush}"/>
			</MultiTrigger>
		</Style.Triggers>
	</Style>
	
	<!-- EDGE CONTROL -->
	<Style TargetType="{x:Type GraphSharp_Controls:EdgeControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GraphSharp_Controls:EdgeControl}">
                    <Path Stroke="{TemplateBinding Foreground}"
                          StrokeThickness="{TemplateBinding StrokeThickness}"
                          MinWidth="1"
                          MinHeight="1"
                          ToolTip="{TemplateBinding ToolTip}"
                          x:Name="edgePath">
                        <Path.Data>
                            <PathGeometry>
                                <PathGeometry.Figures>
                                    <MultiBinding Converter="{StaticResource routeToPathConverter}">
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Source.(GraphSharp_Controls:GraphCanvas.X)" />
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Source.(GraphSharp_Controls:GraphCanvas.Y)" />
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Source.ActualWidth" />
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Source.ActualHeight" />
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Target.(GraphSharp_Controls:GraphCanvas.X)" />
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Target.(GraphSharp_Controls:GraphCanvas.Y)" />
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Target.ActualWidth" />
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Target.ActualHeight" />
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="RoutePoints" />
                                    </MultiBinding>
                                </PathGeometry.Figures>
                            </PathGeometry>
                        </Path.Data>                        
                    </Path>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger"
                Value="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" />
        <Setter Property="MinWidth"
                Value="1" />
        <Setter Property="MinHeight"
                Value="1" />
        <Setter Property="Background"
                Value="Red" />
        <Setter Property="Foreground"
                Value="Silver" />
        <Setter Property="Opacity"
                Value="0.5" />
        <Style.Triggers>
            <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted"
                     Value="True">
                <Setter Property="Foreground"
                        Value="{DynamicResource HighlightedEdgeBrush}" />
            </Trigger>
            <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
                     Value="True">
                <Setter Property="Foreground"
                        Value="{DynamicResource HighlightedEdgeBrush}" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
                               Value="True" />
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo"
                               Value="InEdge" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground"
                        Value="{DynamicResource SemiHighlightedInEdgeBrush}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
                               Value="True" />
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo"
                               Value="OutEdge" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground"
                        Value="{DynamicResource SemiHighlightedOutEdgeBrush}" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
	
	<Style TargetType="{x:Type GraphSharp_Controls:CompoundVertexControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GraphSharp_Controls:CompoundVertexControl}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
							Padding="10">
                        <GroupBox>
                            <GroupBox.Header>
                                adfajkdsfklad
                            </GroupBox.Header>

                            <ItemsControl x:Name="PART_InnerCanvas"
                                          ItemsSource="{TemplateBinding Vertices}">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel Orientation="Vertical" />
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                        </GroupBox>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        
        <Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger"
                Value="{Binding RelativeSource={RelativeSource Self},Path=IsMouseOver}" />
        <Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.IsDragEnabled"
                Value="True" />
        <Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.X"
                Value="{Binding RelativeSource={RelativeSource Self},Path=(GraphSharp_Controls:GraphCanvas.X),Mode=TwoWay}" />
        <Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.Y"
                Value="{Binding RelativeSource={RelativeSource Self},Path=(GraphSharp_Controls:GraphCanvas.Y),Mode=TwoWay}" />
        <Setter Property="BorderThickness"
                Value="22" />
        <Setter Property="BorderBrush"
                Value="Silver" />
        <Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0"
                                     EndPoint="1,1">
                    <GradientStop Color="White"
                                  Offset="0" />
                    <GradientStop Color="BurlyWood"
                                  Offset="1" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="LayoutMode"
                     Value="Automatic">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type GraphSharp_Controls:CompoundVertexControl}">
                            <Border BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Background="{TemplateBinding Background}"
									Padding="10">
                                <GroupBox>
                                    <GroupBox.Header>
                                        wdawew
                                    </GroupBox.Header>

                                    <ItemsControl x:Name="PART_InnerCanvas"
                                                  ItemsSource="{TemplateBinding Vertices}">
                                        <ItemsControl.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <GraphSharp_Controls:GraphCanvas Background="White"/>
                                            </ItemsPanelTemplate>
                                        </ItemsControl.ItemsPanel>
                                    </ItemsControl>
                                </GroupBox>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0,0"
                                             EndPoint="1,1">
                            <GradientStop Color="White"
                                          Offset="0" />
                            <GradientStop Color="Silver"
                                          Offset="1" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted"
                     Value="True">
                <Setter Property="BorderBrush"
                        Value="Orange" />
                <Setter Property="BorderThickness"
                        Value="2" />
            </Trigger>
            <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
                     Value="True">
                <Setter Property="BorderBrush"
                        Value="Yellow" />
                <Setter Property="BorderThickness"
                        Value="2" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
                               Value="True" />
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo"
                               Value="Source" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush"
                        Value="Red" />
                <Setter Property="BorderThickness"
                        Value="2" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
                               Value="True" />
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo"
                               Value="Target" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush"
                        Value="Blue" />
                <Setter Property="BorderThickness"
                        Value="2" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>